package com.bom_samaritano.ui;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.bom_samaritano.R;
import com.bom_samaritano.util.Constantes;

public class OferecerProcurar extends Activity {

	private Button oferecer;
	private Button procurar;
	private Button logout;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tela_oferecer_procurar);

		oferecer = (Button) findViewById(R.id.button_oferecer);
		oferecer.setOnClickListener(new click(Constantes.OFERECER));

		procurar = (Button) findViewById(R.id.button_procurar);
		procurar.setOnClickListener(new click(Constantes.PROCURAR));

		logout = (Button) findViewById(R.id.button_logout);
		logout.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				SharedPreferences pref = getSharedPreferences(Constantes.FILE,
						Context.MODE_PRIVATE);
				SharedPreferences.Editor editor = pref.edit();
				editor.putBoolean(Constantes.LOGADO, false);
				editor.commit();

				startActivity(new Intent(OferecerProcurar.this, Login.class));

			}
		});

	}

	private class click implements OnClickListener {

		int category;

		public click(int category) {
			this.category = category;
		}

		@Override
		public void onClick(View v) {
			Intent it = new Intent(OferecerProcurar.this, TracarRota.class);
			it.putExtra(Constantes.CATEGORY, category);
			startActivity(it);
		}
	}
}
